package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	UserType       int64  `gorm:"type:int; not null; comment:'0-患者,1-管理员'"`
	Phone          string `gorm:"type:char(11); not null; unique; comment:'手机号'"`
	BindStatus     int64  `gorm:"type:int; unique; comment:'0-未绑定微信，1-已绑定，对患者有效'"`
	RealNameStatus int64  `gorm:"type:int; not null;comment:'0-未实名,1-已实名 患者需要实名才能预约'"`
	RealName       string `gorm:"type:varchar(50); not null; comment:'患者展示姓名'"`
	IdCard         string `gorm:"type:char(18); not null; comment:'身份证'"`
	UserStatus     int64  `gorm:"type:int; not null; comment:'0-正常,1-禁用'"`
}

func (u *User) GetPhoneByPhone(db *gorm.DB, phone string) error {
	err := db.Where("phone=?", phone).Find(&u).Error
	return err
}

func (u *User) CreateUser(db *gorm.DB) error {
	err := db.Create(&u).Error
	return err
}
